package sparrowGui
{
	import flash.display.DisplayObjectContainer;
	import flash.display.InteractiveObject;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	
	/**
	 * 类似鼠标右链的弹窗提示窗效果
	 * @author Pelephone
	 */
	public class PopupTip extends BaseTip
	{
//		private var _mask:Sprite;
//		private var _tweenTime:int;
//		private var _upDown:int;
		
		public function PopupTip(parent:DisplayObjectContainer, vars:Object=null)
		{
			super(parent,vars);
//			_tweenTime = vars.tweenTime;
//			_upDown = style.upDown;
		}
		
/*		override protected function init():void
		{
		}
		
		override public function update(data:Object):void
		{
			super.update(data);
		}*/
		
		override protected function onEvt(e:Event):void
		{
			switch(e.type){
				case MouseEvent.CLICK:
					_parent.addChild(this);
					this.visible = true;
					_overObj = e.currentTarget as InteractiveObject;
					update(getTipObj(overTip));
					setTipPosi(overTip);
					addEvt()
					break;
				case Event.MOUSE_LEAVE:
				case MouseEvent.MOUSE_UP:
					hiddenOverTip();
					break;
			}
		}
		
		/**
		 * mask遮照项高
		 * @return 
		
		override public function get panHeight():Number
		{
			if(_list.height<style.height) return _list.height;
			else return style.height;
		} */
		
		/**
		 * 覆盖高属性
		 
		override public function set height(h:Number):void
		{
			_list.height = h - style.spacing;
			super.height = h;
		}*/
		
		private function hiddenOverTip():void
		{
			_overObj = null;
			if(this.parent) parent.removeChild(this);
			this.visible = false;
			removeEvt();
		}
		
		override public function addTipBtn(tipObj:InteractiveObject, tipData:Object):void
		{
			killTip(tipObj);	//为了防止重复给一个按钮添加了两次事件,添加新事件前将其移除
			tipObj.addEventListener(MouseEvent.CLICK,onEvt);
			super.addTipBtn(tipObj,tipData);
		}
		
		override public function killTip(tipObj:InteractiveObject):void
		{
			tipObj.removeEventListener(MouseEvent.CLICK,onEvt);
			super.killTip(tipObj);
		}
	}
}